package factory.method.abstractt.tablefactory;

import factory.method.abstractt.factory.Item;
import factory.method.abstractt.factory.Tray;

public class TableTray extends Tray {
    public TableTray(String caption) {
        super(caption);
    }

    @Override
    public String makeHtml() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("<td>");
        buffer.append("<table width=\"100%\" border=\"1\"><tr>");
        buffer.append("<td bgcolor=\"#cccc\" align\"center\" colspan=\"").append(tray.size()).append("\"><b>");
        buffer.append(caption).append("</b></td></tr><tr>\n");
        for (Item item : tray) {
            buffer.append(item.makeHtml());
        }
        buffer.append("</tr></table></td>");
        return buffer.toString();
    }
}
